package main.util;

import java.util.LinkedList;
import java.util.List;

public class RouterConfig {

	private int id;
	private int port;
	private String ip;
	
	private List<Integer> neighbours;
	private List<Integer> neighbourDistances;
	private List<Integer> neighbourPorts;
	private List<String> neighbourIps;
	
	public RouterConfig(int id, int port, String ip) {
		this.id = id;
		this.port = port;
		this.ip = ip;
		
		neighbours = new LinkedList<Integer>();
		neighbourDistances = new LinkedList<Integer>();
		neighbourPorts = new LinkedList<Integer>();
		neighbourIps = new LinkedList<String>();
	}
	
	public void addNeighbour(int neighbourId, int neighbourPort, String neighbourIp, int distance){
		this.neighbours.add(neighbourId);
		this.neighbourIps.add(neighbourIp);
		this.neighbourPorts.add(neighbourPort);
		this.neighbourDistances.add(distance);
	}
	
	public int[] getNeighbours(){
		int[] ids = new int[this.neighbours.size() + 1];
		
		int index = 1;
		for (Integer id : this.neighbours){
			ids[index] = id;
			index++;
		}
		
		return ids;
	}
	
	public int[] getNeighbourPorts() {
		int[] ports = new int[this.neighbourPorts.size() + 1];
		
		int index = 1;
		for (Integer port : this.neighbourPorts){
			ports[index] = port;
			index++;
		}
		
		return ports;
	}
	
	public int[] getDistances(){
		int[] distances = new int[this.neighbourDistances.size() + 1];
		
		int index = 1;
		for (Integer distance : this.neighbourDistances){
			distances[index] = distance;
			index++;
		}
		
		return distances;
	}
	
	public String[] getIps(){
		String[] ips = new String[this.neighbourIps.size() + 1];
		
		int index = 1;
		for (String ip : this.neighbourIps){
			ips[index] = ip;
			index++;
		}
		
		return ips;
	}
	
	public int getId() {
		return id;
	}

	public int getPort() {
		return port;
	}

	public String getIp() {
		return ip;
	}
}